licenses(["notice"])

cc_library(
    name = "sketch",
    hdrs = ["sketch.h"],
    deps = [":utils"],
)

cc_library(
    name = "utils",
    srcs = ["utils.cc"],
    hdrs = [
        "utils.h",
    ],
    deps = [
        "//external:gflags",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/random:bit_gen_ref",
        "@com_google_absl//absl/random:distributions",
    ],
)

cc_library(
    name = "countmin",
    srcs = ["countmin.cc"],
    hdrs = ["countmin.h"],
    deps = [
        ":sketch",
        ":utils",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/random:bit_gen_ref",
        "@com_google_absl//absl/random:distributions",
    ],
)

cc_library(
    name = "benchmark_utils",
    testonly = 1,
    srcs = ["benchmark_utils.cc"],
    hdrs = ["benchmark_utils.h"],
    deps = [
        ":sketch",
        ":utils",
        "@com_google_benchmark//:benchmark",
    ],
)

cc_test(
    name = "countmin_test",
    srcs = ["countmin_test.cc"],
    deps = [
        ":countmin",
        ":utils",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "lossy_count",
    srcs = ["lossy_count.cc"],
    hdrs = ["lossy_count.h"],
    deps = [
        ":countmin",
        ":sketch",
        ":utils",
    ],
)

cc_binary(
    name = "lossy_count_benchmark",
    testonly = 1,
    srcs = ["lossy_count_benchmark.cc"],
    deps = [
        ":benchmark_utils",
        ":lossy_count",
        ":sketch",
        ":utils",
        "@com_google_benchmark//:benchmark_main",
    ],
)

cc_library(
    name = "lossy_weight",
    srcs = ["lossy_weight.cc"],
    hdrs = ["lossy_weight.h"],
    deps = [
        ":countmin",
        ":sketch",
        ":utils",
    ],
)

cc_test(
    name = "lossy_weight_test",
    srcs = ["lossy_weight_test.cc"],
    deps = [
        ":lossy_weight",
        ":utils",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_binary(
    name = "lossy_weight_benchmark",
    testonly = 1,
    srcs = ["lossy_weight_benchmark.cc"],
    deps = [
        ":benchmark_utils",
        ":lossy_weight",
        ":sketch",
        ":utils",
        "@com_google_benchmark//:benchmark_main",
    ],
)

cc_library(
    name = "frequent",
    srcs = ["frequent.cc"],
    hdrs = ["frequent.h"],
    deps = [
        ":countmin",
        ":sketch",
        ":utils",
        "@com_google_absl//absl/container:flat_hash_map",
    ],
)

cc_test(
    name = "frequent_test",
    srcs = ["frequent_test.cc"],
    deps = [
        ":frequent",
        ":utils",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_binary(
    name = "frequent_benchmark",
    testonly = 1,
    srcs = ["frequent_benchmark.cc"],
    deps = [
        ":benchmark_utils",
        ":frequent",
        ":sketch",
        ":utils",
        "@com_google_benchmark//:benchmark_main",
    ],
)

cc_binary(
    name = "run_sketches",
    srcs = ["run_sketches.cc"],
    deps = [
        ":countmin",
        ":frequent",
        ":lossy_count",
        ":lossy_weight",
        ":sketch",
        ":utils",
        "//external:gflags",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/memory",
    ],
)
